|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SimpleRemoteInterfaceBasedWrapperClassWriter.java | 91.7% | 98.1% | 100% | 97.1% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs;
|
|
17 |
|
|
18 |
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
|
19 |
import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
21 |
|
|
22 |
import java.util.ArrayList;
|
|
23 |
import java.util.Iterator;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* @author Srinath Perera(hemapani@opensource.lk)
|
|
27 |
*/
|
|
28 |
public abstract class SimpleRemoteInterfaceBasedWrapperClassWriter extends EJBBasedWrapperClassWriter { |
|
29 |
|
|
30 |
/**
|
|
31 |
* @param j2eewscontext
|
|
32 |
* @throws GenerationFault
|
|
33 |
*/
|
|
34 | 8 |
public SimpleRemoteInterfaceBasedWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
|
35 |
throws GenerationFault {
|
|
36 | 8 |
super(j2eewscontext);
|
37 | 8 |
seiName = context.getEjbRemoteInterface(); |
38 |
} |
|
39 |
|
|
40 |
protected abstract String getJNDIInitialContextFactory();
|
|
41 |
|
|
42 |
protected abstract String getJNDIHostAndPort();
|
|
43 |
|
|
44 | 8 |
protected String getimplementsPart() {
|
45 | 8 |
return " implements org.apache.geronimo.ews.ws4j2ee.wsutils.ContextAccessible"; |
46 |
} |
|
47 |
|
|
48 | 8 |
protected void writeMethods() throws GenerationFault { |
49 | 8 |
out.write("\tpublic void setMessageContext(org.apache.axis.MessageContext msgcontext){;\n");
|
50 | 8 |
out.write("\t\tthis.msgcontext = msgcontext;\n");
|
51 | 8 |
out.write("\t}\n");
|
52 | 8 |
writeGetRemoteRef(classname); |
53 | 8 |
String parmlistStr = null;
|
54 | 8 |
ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations(); |
55 | 8 |
for (int i = 0; i < operations.size(); i++) { |
56 | 27 |
parmlistStr = "";
|
57 | 27 |
SEIOperation op = (SEIOperation) operations.get(i); |
58 | 27 |
String returnType = op.getReturnType(); |
59 | 27 |
if (returnType == null) |
60 | 3 |
returnType = "void";
|
61 | 27 |
out.write("\tpublic " + returnType + " " + op.getMethodName() + "("); |
62 | 27 |
Iterator pas = op.getParameterNames().iterator(); |
63 | 27 |
boolean first = true; |
64 | 27 |
while (pas.hasNext()) {
|
65 | 42 |
String name = (String) pas.next(); |
66 | 42 |
String type = op.getParameterType(name); |
67 | 42 |
if (first) {
|
68 | 23 |
first = false;
|
69 | 23 |
out.write(type + " " + name);
|
70 | 23 |
parmlistStr = parmlistStr + name; |
71 |
} else {
|
|
72 | 19 |
out.write("," + type + " " + name); |
73 | 19 |
parmlistStr = parmlistStr + "," + name;
|
74 |
} |
|
75 |
} |
|
76 | 27 |
out.write(") throws java.rmi.RemoteException");
|
77 | 27 |
ArrayList faults = op.getFaults(); |
78 | 27 |
for (int j = 0; j < faults.size(); j++) { |
79 | 0 |
out.write("," + (String) faults.get(j));
|
80 |
} |
|
81 | 27 |
out.write("{\n");
|
82 | 27 |
out.write("\t\tif(ejb == null)\n");
|
83 | 27 |
out.write("\t\t\tejb = getRemoteRef();\n");
|
84 | 27 |
if (!"void".equals(returnType)) |
85 | 24 |
out.write("\t\treturn ejb." + op.getMethodName() + "(" + parmlistStr + ");\n"); |
86 |
else
|
|
87 | 3 |
out.write("\t\tejb." + op.getMethodName() + "(" + parmlistStr + ");\n"); |
88 | 27 |
out.write("\t}\n");
|
89 |
} |
|
90 |
//out.write("}\n");
|
|
91 |
} |
|
92 |
|
|
93 | 8 |
private void writeGetRemoteRef(String classname) { |
94 | 8 |
out.write("\tpublic " + seiName + " getRemoteRef()throws org.apache.axis.AxisFault{\n"); |
95 |
|
|
96 |
//TODO remove the security code for the time been
|
|
97 |
// out.write("\t\ttry {\n");
|
|
98 |
// out.write("\t\tif(msgcontext == null){\n");
|
|
99 |
// out.write("\t\t msgcontext = org.apache.axis.MessageContext.getCurrentContext();\n");
|
|
100 |
// out.write("\t\t}\n");
|
|
101 |
// out.write("\t\tif(msgcontext == null){\n");
|
|
102 |
// out.write("\t\t throw new RuntimeException(\"Message Context can not be null\");\n");
|
|
103 |
// out.write("\t\t}\n");
|
|
104 |
//
|
|
105 |
// out.write("\t\torg.apache.geronimo.ews.ws4j2ee.context.security.SecurityContext4J2EE seccontext =\n");
|
|
106 |
// out.write("\t\t (org.apache.geronimo.ews.ws4j2ee.context.security.SecurityContext4J2EE)msgcontext\n");
|
|
107 |
// out.write("\t\t.getProperty(org.apache.ws.axis.security.WSS4J2EEConstants.SEC_CONTEXT_4J2EE);\n");
|
|
108 |
// out.write("\t\tif(seccontext != null){\n");
|
|
109 |
// out.write("\t\t\t javax.security.auth.callback.CallbackHandler handler\n");
|
|
110 |
// out.write("\t\t\t = seccontext.getPWDCallbackHandler4J2EE();\n");
|
|
111 |
// out.write("\t\t\t if(handler != null){\n");
|
|
112 |
// out.write("\t\t\t javax.security.auth.login.LoginContext lc\n");
|
|
113 |
// out.write("\t\t\t = new javax.security.auth.login.LoginContext(\"TestClient\", handler);\n");
|
|
114 |
// out.write("\t\t\t lc.login();\n");
|
|
115 |
// out.write("\t\t\t }\n");
|
|
116 |
// out.write("\t\t}\n");
|
|
117 |
//
|
|
118 |
// out.write("\t\t}catch (javax.security.auth.login.LoginException e) {\n");
|
|
119 |
// out.write("\t\t e.printStackTrace();\n");
|
|
120 |
// out.write("\t\t throw org.apache.axis.AxisFault.makeFault(e);\n");
|
|
121 |
// out.write("\t\t}\n");
|
|
122 |
|
|
123 | 8 |
out.write("\t\ttry{\n");
|
124 |
// use the properties set
|
|
125 |
// out.write("\t\t\tjava.util.Properties env = new java.util.Properties();\n");
|
|
126 |
// out.write("\t\t\tenv.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,\""+getJNDIInitialContextFactory()+"\");\n");
|
|
127 |
// out.write("\t\t\tenv.put(javax.naming.Context.PROVIDER_URL, \""+getJNDIHostAndPort()+"\");\n");
|
|
128 | 8 |
out.write("\t\t\tjava.util.Properties env = new java.util.Properties();\n");
|
129 | 8 |
out.write("\t\t\tenv.load(getClass().getClassLoader().getResourceAsStream(\"jndi.properties\"));\n");
|
130 |
//use the propertyfile
|
|
131 |
// out.write("\t\t\torg.apache.geronimo.ews.ws4j2ee.wsutils.PropertyLoader ploader = new org.apache.geronimo.ews.ws4j2ee.wsutils.PropertyLoader();\n");
|
|
132 |
// out.write("\t\t\tjava.util.Properties env = " +
|
|
133 |
// "ploader.loadProperties(\"jndi.properties\");\n");
|
|
134 |
|
|
135 | 8 |
out.write("\t\t\tjavax.naming.Context initial = new javax.naming.InitialContext(env);\n");
|
136 |
|
|
137 | 8 |
String ejbname = j2eewscontext.getWSCFContext().getWscfport().getServiceImplBean().getEjblink(); |
138 | 8 |
out.write("\t\t\tObject objref = initial.lookup(\"ejb/" + ejbname + "\");\n"); |
139 | 8 |
String ejbhome = j2eewscontext.getEJBDDContext().getEjbhomeInterface(); |
140 | 8 |
out.write("\t\t\t" + ejbhome + " home = \n\t\t\t\t(" + ejbhome |
141 |
+ ")javax.rmi.PortableRemoteObject.narrow(objref," + ejbhome + ".class);\n"); |
|
142 | 8 |
out.write("\t\t\treturn home.create();\n");
|
143 | 8 |
out.write("\t\t}catch (Exception e) {\n");
|
144 | 8 |
out.write("\t\t throw org.apache.axis.AxisFault.makeFault(e);\n");
|
145 | 8 |
out.write("\t\t}\n");
|
146 | 8 |
out.write("\t}\n");
|
147 |
} |
|
148 |
} |
|
149 |
|
|